/**
 * 
 */
package org.cuatrovientos.buylist;

/**
 * 
 * @author teodor_mivovan
 *
 */
public class BuyList {

/**
 * shows the menu
 */
        public static void showMenu() {
                
        System.out.println("Menu");
        System.out.println("1.Show list");
        System.out.println("2.Insert in list");
        System.out.println("3.Delete element on list");
        System.out.println("4.Exit");
                
                
        }
        
        /**
         * starts empty array
         * @param list
         */
        public static void initializerVoid(String[] list){
                
                for (int i = 0; i < list.length; i++) {
                        list[i]=" ";
                }
        }
        
        /**
         * inserts in the array
         * @param list
         * @param newElement
         * @return
         */
        public static int insertElement (String[] list, String newElement){
                int position=0;
                for (int i = 0; i < list.length; i++ ) {
                        if (list[i]== " ") {
                                list[i]=newElement;
                                position=i;
                        }
                }
                
                return position;
        }
        
        /**
         * deletes one element in array
         * @param list
         * @param aux
         */
        public static void deleteElement (String[] list, int aux) {
                
        	for (int i = 0; i < list.length; i++ ) {
                	if(i>=aux){
                		if(i==list.length){break;}
                		list[i] = list[i+1];
                	} 
              
                }
        }
        
        
        
        /**
         * shows array
         * @param listaCompra
         */
        public static void showsList (String[] list) {
                
                for (int i = 0; i < list.length; i++) {
                        System.out.println(i + " " + list[i]);
                }
                
        }
}